

package com.example.administrator.caigou51.recyclerCard.cardView;

import android.content.Context;
import android.content.Intent;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;


import com.example.administrator.caigou51.R;
import com.example.administrator.caigou51.activity.GBaseActivity;
import com.example.administrator.caigou51.activity.ZhuangQuActivity;
import com.example.administrator.caigou51.global.Constant;
import com.example.administrator.caigou51.recyclerCard.basic.CardItemView;
import com.example.administrator.caigou51.recyclerCard.card.MainPart2Card;
import com.example.administrator.caigou51.request.RequestServerManager;
import com.example.administrator.caigou51.widget.RippleView;


public class MainPart2CardView extends CardItemView<MainPart2Card> {
 	private Context mContext;

    public MainPart2CardView(Context context) {
        super(context);
        mContext=context;
        // TODO Auto-generated constructor stub
    }

    public MainPart2CardView(Context context, AttributeSet attrs) {
        super(context, attrs);
        mContext=context;
        // TODO Auto-generated constructor stub
    }

    public MainPart2CardView(Context context,
                                    AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        mContext=context;
        // TODO Auto-generated constructor stub
    }
    private TextView textViewleft;
    private TextView textViewright;
    private ImageView imageViewHot;
    private ImageView imageViewNew;
    private RippleView rippleViewLeft;
    private RippleView rippleViewRight;
    @Override
    public void build(final MainPart2Card card) {
        // TODO Auto-generated method stub
        super.build(card);
        rippleViewLeft= (RippleView) findViewById(R.id.rippleViewLeft);
        rippleViewLeft.setRippleColor(R.color.color_36cd66);
        rippleViewLeft.setRippleDuration(180);
        rippleViewLeft.setAlpha(100.0f);
        rippleViewRight=(RippleView) findViewById(R.id.rippleViewRight);
        rippleViewRight.setRippleColor(R.color.color_1ca146);
        rippleViewRight.setRippleDuration(180);
        rippleViewRight.setAlpha(100.0f);
        textViewleft= (TextView) findViewById(R.id.textViewleft);
        textViewright= (TextView) findViewById(R.id.textViewright);
        imageViewHot= (ImageView) findViewById(R.id.imageViewHot);
        imageViewNew= (ImageView) findViewById(R.id.imageViewNew);
        if (card.getMainDataBean().getPrefecture().get(card.getIndex())!=null) {
            textViewleft.setText(card.getMainDataBean().getPrefecture().get(card.getIndex()).getCatname());
            if (card.getIndex()==0)
            {
                imageViewHot.setVisibility(View.VISIBLE);
            }else
            {
                imageViewHot.setVisibility(View.INVISIBLE);
            }
            rippleViewLeft.setOnRippleCompleteListener(new RippleView.OnRippleCompleteListener() {
                @Override
                public void onComplete(RippleView rippleView) {
                    Intent intent2 =new Intent(mContext, ZhuangQuActivity.class);
                    intent2.putExtra(ZhuangQuActivity.TitleTag,textViewleft.getText());
                    intent2.putExtra(ZhuangQuActivity.CatIDTag,card.getMainDataBean().getPrefecture().get(card.getIndex()).getCatid()+"");
                    mContext.startActivity(intent2);
                }
            });
            /*textViewleft.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent intent2 =new Intent(mContext, ZhuangQuActivity.class);
                    intent2.putExtra(ZhuangQuActivity.TitleTag,textViewleft.getText());
                    intent2.putExtra(ZhuangQuActivity.CatIDTag,card.getMainDataBean().getPrefecture().get(card.getIndex()).getCatid()+"");
                    mContext.startActivity(intent2);
                }
            });*/
        }else
        {
            textViewleft.setText("");
        }


        if (card.getMainDataBean().getPrefecture().size()>(card.getIndex()+1) && card.getMainDataBean().getPrefecture().get(card.getIndex()+1)!=null) {
            textViewright.setText(card.getMainDataBean().getPrefecture().get(card.getIndex() + 1).getCatname());
            if (card.getIndex()==0)
            {
                imageViewNew.setVisibility(View.VISIBLE);
            }else
            {
                imageViewNew.setVisibility(View.INVISIBLE);
            }
            rippleViewRight.setOnRippleCompleteListener(new RippleView.OnRippleCompleteListener() {
                @Override
                public void onComplete(RippleView rippleView) {
                    Intent intent2 =new Intent(mContext, ZhuangQuActivity.class);
                    intent2.putExtra(ZhuangQuActivity.TitleTag,textViewright.getText());
                    intent2.putExtra(ZhuangQuActivity.CatIDTag,card.getMainDataBean().getPrefecture().get(card.getIndex()+1).getCatid()+"");
                    mContext.startActivity(intent2);
                }
            });
           /* textViewright.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent intent2 =new Intent(mContext, ZhuangQuActivity.class);
                    intent2.putExtra(ZhuangQuActivity.TitleTag,textViewright.getText());
                    intent2.putExtra(ZhuangQuActivity.CatIDTag,card.getMainDataBean().getPrefecture().get(card.getIndex()+1).getCatid()+"");
                    mContext.startActivity(intent2);
                }
            });*/
        }else
        {
            textViewright.setText("");
        }


    }

 /*    @Override
   public void onClick(View v) {
        switch (v.getId())
        {
            case R.id.textViewleft:
                Intent intent =new Intent(mContext, ZhuangQuActivity.class);
                intent.putExtra(ZhuangQuActivity.TitleTag,textViewleft.getText());
                mContext.startActivity(intent);
                break;
            case R.id.textViewright:
                Intent intent2 =new Intent(mContext, ZhuangQuActivity.class);
                intent2.putExtra(ZhuangQuActivity.TitleTag,textViewright.getText());
                intent2.putExtra(ZhuangQuActivity.CatIDTag,)
                mContext.startActivity(intent2);
                break;
        }
    }*/


}
